package com.abner.springcloud.consumer.movie.config;

import feign.Contract;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.context.annotation.Bean;

/**
 * @Author: Abner.Jiang
 * @Description:  该类是Feign 的配置类
 *          注意： 该类可以不写@Configuration注解；如果加了@Configuration注解，那么该类就不能放在
 *          主应用程序上下文@ComponentScan所扫描的包中
 * @Date: Created on 2019/12/19 09:29
 * @ProjectName: springcloud-provider-user
 */
public class FeignConfiguration {

    /**
     * 将契约改为feign的原生默认契约。这样就可以使用feign自带的注解
     * @return 默认的feign契约
     */
    @Bean
    public Contract feignContract(){
        return new Contract.Default();
    }

    /**
     * 添加拦截器
     * 基于Http Basic认证后才能调用
     * @return
     */
    @Bean
    public BasicAuthRequestInterceptor basicAuthRequestInterceptor(){
        return new BasicAuthRequestInterceptor("user","123");
    }
}
